﻿Imports Microsoft.VisualBasic

Public MustInherit Class CPage : Inherits System.Web.UI.Page

#Region "Default Events"
    Private Sub Page_Init(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Init
        Me.Layout = CConfig.layout
        PageInit()
        'Me.PageTitle = Me.Title
    End Sub
    Private Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
        If Page.IsPostBack then Exit Sub
        PageLoad()
    End Sub
    Private Sub Page_PreRender(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.PreRender
        PagePreRender()
    End Sub
#End Region

#Region "Virtual"
    'Called Automatically
    Protected Overridable Sub PageInit()
    End Sub
    Protected Overridable Sub PageLoad()
    End Sub
    Protected Overridable Sub PagePreRender()
    End Sub

    'Name standardisation only
    Protected Overridable Sub PageSave()
    End Sub
#End Region

#Region "MasterPage"
    Public Shadows ReadOnly Property Master() As CMasterPage
        Get
            Return CType(MyBase.Master, CMasterPage)
        End Get
    End Property
    Protected WriteOnly Property PageHeading() As String
        Set(ByVal value As String)
            Master.PageHeading = value
        End Set
    End Property
#End Region

#Region "Utilities"
    Public Property PageTitle() As String
        Get
            Return MyBase.Title
        End Get
        Set(ByVal value As String)
            MyBase.Title = value
            Master.PageHeading = value
        End Set
    End Property
#End Region

#Region "Custom Controls - Mode/Layout"
    'Page - Editable/Disabled/Locked
    Public Overridable WriteOnly Property Mode() As EControlMode
        Set(ByVal value As EControlMode)
            SetControlMode(Me, value)
        End Set
    End Property
    'Page - Horizontal/Vertical/Flow
    Public WriteOnly Property Layout() As ELayout
        Set(ByVal value As ELayout)
            SetLayout(Me, value)
        End Set
    End Property

    'Overloads for smaller subsets
    Public Sub SetControlMode(ByVal parent As Control, ByVal value As EControlMode)
        CCustomControl.SetControlMode(Me, value)
    End Sub
    Public Sub SetLayout(ByVal parent As Control, ByVal value As ELayout)
        CCustomControlContainer.SetLayout(Me, value)
    End Sub
#End Region

End Class
